//
//  JSLSetController.m
//  JingleSpeedLoan
//
//  Created by 宋志彬 on 2018/7/29.
//  Copyright © 2018年 宋质彬. All rights reserved.
//

#import "JSLSetController.h"
#import "JSLSettingCell.h"
#import "JSLAboutUsController.h"
#import "JSLCoopertionController.h"
#import "JSLFeedBackController.h"

@interface JSLSetController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic , strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *arrDataSource;

@end

@implementation JSLSetController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"设置";
    [self tableView];
    
    [self baseConfig:PageGobackTypePop];
    

    self.tableView.tableFooterView = [JSLKitFactory jsl_viewWithFrame:CGRectZero backgroundColor:BACKGROUND_COLOR superView:nil];
    
    NSDictionary*infoDictionary=[[NSBundle mainBundle] infoDictionary];
    NSString*app_Version=[infoDictionary objectForKey:@"CFBundleShortVersionString"];
    NSString *version= [NSString stringWithFormat:@"V%@",app_Version];

    self.arrDataSource = [NSMutableArray arrayWithArray:@[
                                                           
                                                           @{
                                                               @"title" : @"商务合作",
                                                               @"flagStr" : @"shhz",
                                                               @"sutitle" : @""
                                                               },
                                                           @{
                                                               @"title" : @"意见反馈",
                                                               @"flagStr" : @"yjfk",
                                                               @"sutitle" : @""
                                                               },
                                                           @{
                                                               @"title" : @"关于我们",
                                                               @"flagStr" : @"gywm",
                                                               @"sutitle" : @""
                                                               },
                                                           @{
                                                               @"title" : @"版本号",
                                                               @"flagStr" : @"bbh",
                                                               @"sutitle" : version
                                                               }
                                                           ]];

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.arrDataSource.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    JSLSettingCell *cell = [JSLSettingCell cellWithTableView:tableView];
    [cell configSettingViewData:self.arrDataSource[indexPath.row]];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSString * flagStr = self.arrDataSource[indexPath.row][@"flagStr"];
    
    if ([flagStr isEqualToString:@"shhz"]) {
        JSLCoopertionController *vc = [[JSLCoopertionController alloc] init];
        [self pushViewController:vc animated:YES];
    }else if ([flagStr isEqualToString:@"yjfk"]){
        JSLFeedBackController *vc = [[JSLFeedBackController alloc] init];
        [self pushViewController:vc animated:YES];
    }else if ([flagStr isEqualToString:@"gywm"]){
        JSLAboutUsController * vc = [[JSLAboutUsController alloc] init];
        [self pushViewController:vc animated:YES];
    }else if ([flagStr isEqualToString:@"bbh"]){
        
    }
}


#pragma mark - get
- (UITableView *)tableView{
    if (_tableView == nil) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-64 -49 ) style:UITableViewStylePlain];
        _tableView.separatorStyle = UITableViewCellSelectionStyleNone;
        _tableView.scrollEnabled = YES;
        _tableView.rowHeight = 50*AutoSizeScaleYY;
        _tableView.backgroundColor = BACKGROUND_COLOR;
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        [self.view addSubview:_tableView];
        
        _tableView.tableHeaderView = [JSLKitFactory jsl_viewWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 10*AutoSizeScaleYY) backgroundColor:BACKGROUND_COLOR superView:nil];
        
    }
    
    return _tableView;
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
